<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../resources/common.js"></script>
<script src="../resources/picker-common.js"></script>
<script src="../calendar-picker/resources/calendar-picker-common.js"></script>
</head>
<body>
<input type="month" value="2021-07">
<script>

promise_test(() => {
  let element = document.querySelector('input[type="month"]');
  return openPickerWithPromise(element)
  .then(() => {
    // Make the picker dismiss synchronously so we don't need to insert
    // an artificial delay in the test
    internals.pagePopupWindow.CalendarPicker.commitDelayMs = 0;

    clickClearMonthButton();

    assert_equals(element.value, "", "Clear button should have updated in-page control to empty string.");
    assert_equals(internals.pagePopupWindow, null, "Click on Clear button should close popup.");
  });
}, `Calendar picker: Clear button for input[type="month"] should clear date`);

</script>
</body>
</html>
